<!-- 分类授权编辑页面 -->
<extend name="Public/baseConf" />

<block name="style">
</block>

<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-4">
	        <h2>分类授权</h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li><a href="{:U('AuthManager/index')}">授权管理</a></li>
	            <li class="active">
	                <strong>分类授权</strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-6">
    		<div class="title-action">
           	<select name="group" class="form-control">
				<volist name="auth_group" id="vo">
					<option value="{:U('AuthManager/category',array('group_id'=>$vo['id'],'group_name'=>$vo['title']))}" <eq name="vo['id']" value="$this_group['id']">selected</eq> >{$vo.title}</option>
				</volist>
			</select></div>
	    </div>
	    <div class="col-lg-2">
            <div class="title-action">
 				<button class="btn btn-primary ajax-post" type="submit" target-form="save-category"><i class="fa fa-check"></i>保存</button>
	            <a class="btn btn-warning" type="submit" href="{:U('index')}"><i class="fa fa-reply"></i>返回</a>
            </div>
        </div>
	</div> 
</block>
<block name="body">
<div class="tabs-container">
    <ul class="nav nav-tabs">
        <li><a href="{:U('AuthManager/access',array('group_name'=>I('group_name') ,'group_id'=> I('group_id')))}"><i class="blue fa  fa-folder-open  bigger-110"></i>访问授权</a></li>
        <li class="active" ><a href="#tabs-2"><i class="blue fa fa-barcode  bigger-110"></i>分类授权</a></li>
		<li><a href="{:U('AuthManager/user',array('group_name'=>I('group_name') ,'group_id'=> I('group_id')))}"><i class="blue fa fa-user  bigger-110"></i>成员授权</a></li>
    </ul>
    <!-- 表格列表 -->
    <div class="tab-content">
  		<div id="tab-2" class="tab-pane active">
	 	<div class="panel-body">
	        <form class="save-category" action="{:U('AuthManager/addToCategory')}" method="post" enctype="application/x-www-form-urlencoded">
	            <input type="hidden" name="group_id" value="{:I('group_id')}">
	            <table class="table table-striped table-bordered table-hover dataTables-example">
               	  <thead>
                  <tr>
						<!-- <th class="center">折叠</th> -->
						<th class="center">选择</th>
						<th class="center">栏目名称</th>
                  </tr>
                  </thead>
                  <tbody>
	                {:R('AuthManager/tree', array($group_list))}
	              </tbody>
	            </table>
	        </form>
        </div>
        </div>
    </div>
</div>
<!-- /表格列表 -->
</block>
<block name="script">
<script type="text/javascript">
    +function($){
        /* 分类展开收起 */
        $(".haschild").find("td i").addClass("fa fa-minus")
            .click(function(){
                var self = $(this);
                if(self.hasClass("fa fa-minus")){
                    self.closest("tr").next().slideUp("fast", function(){
                        self.removeClass("fa fa-minus").addClass("fa fa-plus");
                    });
                } else {
                    self.closest("tr").next().slideDown("fast", function(){
                        self.removeClass("fa fa-plus").addClass("fa fa-minus");
                    });
                }
            });

        var auth_groups = [{$authed_group}];
        $('.cate_id').each(function(){
            if( $.inArray( parseInt(this.value,10),auth_groups )>-1 ){
                $(this).prop('checked',true);
            }
        });
	    $('select[name=group]').change(function(){
		    location.href = this.value;
	    });
    }(jQuery);
</script>
</block>
